/**
 * Dialog box related methods
 * @author Dong
 */
// import {Message, ElMessageBox} from 'element-ui';

import { ElMessage, ElMessageBox } from 'element-plus'

export const dialog = {
    /**
     * Error message
     * @param msg Reminder information
     * @author Dong
     */
    error: function (msg) {

        ElMessage({
            showClose: true,
            message: msg || 'Error ！',
            type: 'error',
            closeOnClickModal: false
        });

    },
    /**
     * Error message
     * @param vm Vue instance
     * @param msg Reminder information
     * @param confirmCallback Confirm callback
     * @param cancelCallback Cancel callback
     * @author Dong Jiayang
     */
    error2: function (vm, msg, confirmCallback, cancelCallback) {
        ElMessageBox.confirm(msg, 'System prompt', {
            confirmButtonText: 'determine',
            cancelButtonText: 'cancel',
            type: 'error',
            closeOnClickModal: false,
            cancelButtonClass: 'btn cancel',
            confirmButtonClass: 'btn submit'
        }).then(function () {
            if (confirmCallback) {
                confirmCallback();
            }
        }).catch(function () {
            if (cancelCallback) {
                cancelCallback();
            }
        });
    },
    /**
     *Successful operation prompt
     * @param msg Reminder information
     * @author Dong
     */
    success: function (msg) {

        ElMessage({
            showClose: true,
            message: msg || 'Operation successful',
            type: 'success',
            closeOnClickModal: false
        });
    },
    /**
     * Success prompt box
     * @param vm vue
     * @param msg Reminder information
     * @param confirmCallback Confirm callback
     * @param cancelCallback Cancel callback
     * @author Dong
     */
    success2: function (vm, msg, confirmCallback, cancelCallback) {
        ElMessageBox.confirm(msg, 'System prompt', {
            confirmButtonText: 'determine',
            cancelButtonText: 'cancel',
            type: 'success',
            closeOnClickModal: false,
            cancelButtonClass: 'btn cancel',
            confirmButtonClass: 'btn submit'
        }).then(function () {
            if (confirmCallback) {
                confirmCallback();
            }
        }).catch(function () {
            if (cancelCallback) {
                cancelCallback();
            }
        });
    },
    /**
     *Warning prompt
     * @param msg Reminder information
     * @author Dong
     */
    warning: function (msg) {

        ElMessage({
            showClose: true,
            message: msg || '系统警告',
            type: 'warning',
            closeOnClickModal: false
        });
    },
    /**
     * Warning prompt box
     * @param vm Vue instance
     * @param msg Reminder information
     * @param confirmCallback Confirm callback
     * @param cancelCallback Cancel callback
     * @author Dong
     */
    warning2: function (vm, msg, confirmCallback, cancelCallback) {
        ElMessageBox.confirm(msg, 'System prompt', {
            confirmButtonText: 'determine',
            cancelButtonText: 'cancel',
            type: 'warning',
            closeOnClickModal: false,
            cancelButtonClass: 'btn cancel',
            confirmButtonClass: 'btn submit'
        }).then(function () {
            if (confirmCallback) {
                confirmCallback();
            }
        }).catch(function () {
            if (cancelCallback) {
                cancelCallback();
            }
        });
    },
    /**
     *Tips
     * @param msg Reminder information
     * @author Dong
     */
    info: function (msg) {

        ElMessage({
            showClose: true,
            message: msg || 'System prompt',
            closeOnClickModal: false
        });
    },
    /**
     * Reminder information框
     * @param vm Vue instance
     * @param msg Reminder information
     * @param confirmCallback Confirm callback
     * @param cancelCallback Cancel callback
     * @author Dong
     */
    info2: function (vm, msg, confirmCallback, cancelCallback) {
        ElMessageBox.confirm(msg, 'System prompt', {
            confirmButtonText: 'determine',
            cancelButtonText: 'cancel',
            type: 'info',
            closeOnClickModal: false,
            cancelButtonClass: 'btn cancel',
            confirmButtonClass: 'btn submit'
        }).then(function () {
            if (confirmCallback) {
                confirmCallback();
            }
        }).catch(function () {
            if (cancelCallback) {
                cancelCallback();
            }
        });
    },
    /**
     * Confirmation prompt box
     * @param vm Vue instance
     * @param msg Reminder information
     * @param confirmCallback Confirm callback
     * @param cancelCallback Cancel callback
     * @author Dong
     */
    confirm2: function (vm, msg, confirmCallback, cancelCallback) {
        ElMessageBox.confirm(msg, 'System prompt', {
            confirmButtonText: 'determine',
            cancelButtonText: 'cancel',
            type: 'warning',
            closeOnClickModal: false,
            cancelButtonClass: 'btn cancel',
            confirmButtonClass: 'btn submit'
        }).then(function () {
            confirmCallback();
        }).catch(function () {
            if (cancelCallback) {
                cancelCallback();
            }
        });
    }
};
